package com.example.blog.repository;

import com.example.blog.entity.Article;
import com.example.blog.entity.Like;
import com.example.blog.entity.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface LikeRepository extends JpaRepository<Like, Long> {
    Optional<Like> findByUserAndArticle(User user, Article article);
    boolean existsByUserAndArticle(User user, Article article);
    Page<Like> findByUser(User user, Pageable pageable);
    Page<Like> findByArticle(Article article, Pageable pageable);
    long countByArticle(Article article);
} 